package app.server.project.main.service.controller;

import app.server.project.core.constants.Def;
import app.server.project.core.http.RespModel;
import app.server.project.main.service.dto.AddInviteReq;
import app.server.project.main.service.dto.invite.InviteDto;
import app.server.project.main.service.dto.invite.InviteFriendReq;
import app.server.project.main.service.service.ActiveService;
import app.server.project.main.service.service.InviteService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 邀请服务
 */
@AllArgsConstructor
@RestController
@RequestMapping("/invite")
public class InviteController {

    private InviteService inviteService;
    private ActiveService activeService;

    /**
     * 拉取邀请好友列表
     *
     * @param userId
     * @param req
     * @return
     */
    @PostMapping("/getInvite")
    public RespModel<InviteDto> getInvite(@RequestHeader(Def.UserId) long userId, @RequestBody InviteFriendReq req) {
        return RespModel.success(this.inviteService.getInvite(userId, req));
    }

    /**
     * 活动链接
     *
     * @return
     */
    @RequestMapping("/getActiveUrl")
    public RespModel<List<String>> getActiveUrl() {
        return RespModel.success(this.activeService.getActiveUrl());
    }

    @RequestMapping("/addInvite")
    public void addInvite(@RequestBody AddInviteReq req) {
        this.inviteService.addInvite(req);
    }
}
